package com.woniuxy.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResponseData<T> {
    private Integer code;
    private String msg;
    private T data;

    //成功，不需要带参数
    public ResponseData<?> OK() {
        return new ResponseData<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getInfo(), null);
    }

    //成功，需要带参数
    public ResponseData<?> OK(T data) {
        return new ResponseData<>(ResponseEnum.SUCCESS.getCode(), ResponseEnum.SUCCESS.getInfo(), data);
    }

    //失败
    public ResponseData<?> Fail(ResponseEnum responseEnum) {
        return new ResponseData<>(responseEnum.getCode(), responseEnum.getInfo(), null);
    }
}
